<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page import="com.infodms.dms.common.Constant"%>
<%@ page import="java.util.*"%>
<%@taglib uri="/jstl/cout" prefix="c" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:include page="${contextPath}/common/jsp_head_new.jsp" />
<title>活动方案下发</title>
<% String contextPath = request.getContextPath();  %>
<script type="text/javascript">
</script>
</head>
<body>
<div class="navigation"><img src="<%=request.getContextPath()%>/img/nav.gif" />&nbsp;当前位置： 市场活动管理 &gt; 活动方案下发&gt; 活动方案制定</div>
<form method="post" name="fm" id="fm">
<div><img class="nav" src="<%=contextPath%>/img/subNav.gif" />&nbsp;业务范围</div>
	<table class="table_query" align="center">
		<tr class= "tabletitle">
			<th align = "right" width="10%">选择业务范围：</th>
			<th align = "left" >
				<select id="areaId" name="areaId" class="short_sel" onchange="getDealerAreaId(this.options[this.options.selectedIndex].value);">
					<c:forEach items="${areaList}" var="po">
						<option value="${po.AREA_ID}">${po.AREA_NAME}</option>
					</c:forEach>
				</select>
				<input type="hidden" name="dealerId" id="dealerId" />
				<input type="hidden" name="area_id" id="area_id" value="" />
				
			</th>
		</tr>
	</table>
	<div><img class="nav" src="<%=contextPath%>/img/subNav.gif" />&nbsp;方案信息</div>
	<table width=100% border="0" align="center" cellpadding="1" cellspacing="1" class="table_query">
		<tr>
			<th colspan="5" align="left">&nbsp;方案录入</th>
		</tr>
		<tr>
			<td class="table_query_2Col_label_6Letter">品牌：</td>
			<td>
				<select name="groupId" id="groupId" class="short_sel" onchange=" toClear();">
					<c:forEach items="${list}" var="list">
						<option value="${list.GROUP_ID}">${list.GROUP_NAME}</option>
					</c:forEach>
				</select>
			</td>
			<td class="table_query_2Col_label_6Letter">活动车型：</td>
			<td>
				<input type="text" class="middle_txt" name="campaignModel" id="campaignModel" readonly="readonly" datatype="0,is_null,1000" size="30"/>
				<input type="hidden" name="modelId" id="modelId"/>
				<!--<input type="button" name="selectbutton" id="selectbutton" class="mini_btn" value="..." onclick="showMaterialGroupToModel('campaignModel','modelId','true','3','true');"/>
				<input name="button3" type="button" class="mini_btn" onclick="showMaterialGroup_market('groupCode','','true','')" value="..." />
				-->
				<input name="button3" type="button" class="mini_btn" onclick="showMaterialCarType_market('groupCode','','true','')" value="..." />
				<input type="button" name="clearbutton" id="clearbutton" class="cssbutton" value="清除" onClick="toClear();"/>
				<input type="hidden" name="area_id" id="area_id" value="" />
			</td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_6Letter">车厂方案编号：</td>
			<td>
				<input type="text" class="middle_txt" name="campaignNo" id="campaignNo" datatype="0,is_digit_letter,30" readonly="readonly" value="${campaignNo}"/>
			</td>
			<td class="table_query_2Col_label_6Letter">方案名称：</td>
			<td>
				<input type="text" class="long_txt" name="campaignName" id="campaignName" datatype="0,is_digit_letter_cn,50" size="30" maxlength="50"/>
			</td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_6Letter">活动开始日期：</td>
			<td>
				<input class="short_txt"  type="text" readonly="readonly" id="startDate" name="startDate" group="startDate,endDate" datatype="0,is_date,10"/>
				<input class="time_ico" type="button" onClick="showcalendar(event, 'startDate', false);" value="&nbsp;" />
			</td>
			<td class="table_query_2Col_label_6Letter">活动结束日期：</td>
			<td>
				<input class="short_txt"  type="text" readonly="readonly" id="endDate" name="endDate" group="startDate,endDate" datatype="0,is_date,10"/>
				<input class="time_ico" type="button" onClick="showcalendar(event, 'endDate', false);" value="&nbsp;" />
			</td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_6Letter">活动主题：</td>
			<td colspan="4">
				<input type="text" class="middle_txt" style="width:450px" name="campaignSubject" id="campaignSubject" datatype="1,is_digit_letter_cn,50" size="90" maxlength="50"/>
			</td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_6Letter">活动对象：</td>
			<td colspan="4">
				<input type="text" class="middle_txt" style="width:450px" name="campaignObject" id="campaignObject" size="90" maxlength="50"/>
			</td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_6Letter">活动目的：</td>
			<td colspan="4">
				<textarea name="campaignPurpose" id="campaignPurpose" rows="4" cols="70"></textarea>
			</td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_6Letter">活动要求：</td>
			<td colspan="4">
				<textarea name="campaignNeed" id="campaignNeed" rows="4" cols="70"></textarea>
			</td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_6Letter">活动主要内容：</td>
			<td colspan="4">
				<textarea name="campaignDesc" id="campaignDesc" rows="4" cols="70"></textarea>
			</td>
		</tr>
	</table>
	<table width=100% border="0" align="center" cellpadding="1" cellspacing="1" class="table_query">
		<tr>
			<td colspan="4" align="center">
				<input type="button" class="cssbutton" name="saveBtn" onClick="toSave();" value="保存"/>
				<input type="button" class="cssbutton" name="button4" onClick="history.back();" value="返回"/>
			</td>
		</tr>
	</table>
</form>
<script type="text/javascript">
    //初始化
    function doInit(){
    	loadcalendar();  //初始化时间控件
    	getDealerAreaId(document.getElementById("areaId").value);
   		
	}
	//选择活动车型
	function toSelect(){
<%--		OpenHtmlWindow('<%=contextPath%>/sales/marketmanage/planissued/ActivitiesPlanMake/queryModelInit.do',800,450);--%>
			OpenHtmlWindow('<%=contextPath%>/sales/marketmanage/planissued/ActivitiesPlanMake/queryModelInit.do',800,450);
	}
	//设置业务范围ID,经销商ID
	function getDealerAreaId(arg){
		var areaObj = document.getElementById("areaId");
		var areaId = areaObj.value.split("|")[0];
		//var dealerId = areaObj.value.split("|")[1];
		//document.getElementById("dealerId").value = dealerId;
		//getAvailableAmount();
		var area_id = arg.split("|")[0];
		document.getElementById("area_id").value=area_id;
		document.getElementById("areaId").value=area_id;
	}
	//保存
	function toSave(){
		if(!isAfterNowTime(document.getElementById('startDate').value)) {
			MyAlert("活动日期不能晚于当前日期！") ;

			return false ;
		}
		
		if(submitForm('fm')){
			document.getElementById("saveBtn").disabled = true ;
			fm.action='<%=contextPath%>/sales/marketmanage/planissued/ActivitiesPlanMake/activitiesPlanMakeSave.do';
			fm.submit();
		}
	}
	//清除功能
	function toClear(){
		document.getElementById("campaignModel").value="";
		document.getElementById("modelId").value="";
	}

	function isAfterNowTime(value) {
		var aDates = value.split("-") ;
		var times = new Date() ;
	    var year = 0;   
	    var month = 0;   
	    var day = 0; 
	          
	    year  = times.getFullYear();   
	    month  = times.getMonth()+1;   
	    day  = times.getDate();       

	    if (aDates[0] < year) {
			return false ;
	    } else {
	    	if (aDates[1] < month) {
	    		return false ;
	        } else {
	        	if (aDates[2] < day) {
	        		return false ;
	            } else {
					return true ;
	            }
	        }
	    }
	}
</script>
</body>
</html>